<template>
    <basic-container>
        <rehydration-vehicle-list ref="rehydrationVehicleListRef" v-show="showType==='list'"
                                  @edit="handleEdit"
                                  @detail="handleDetail"
                                  @add="handleAdd"/>
        <rehydration-vehicle-detail-content v-if="showType==='detail'" :detail="currDetail" @back="handleBack"/>
        <rehydration-vehicle-create-content v-if="showType==='add'" :info="currDetail" @back="handleBack"/>
    </basic-container>
</template>

<script>
import RehydrationVehicleList
    from "@/views/inventory/rehydration-vehicle-management/components/rehydration-vehicle-list";
import RehydrationVehicleDetailContent
    from "@/views/inventory/rehydration-vehicle-management/components/rehydration-vehicle-detail-content";
import RehydrationVehicleCreateContent
    from "@/views/inventory/rehydration-vehicle-management/components/rehydration-vehicle-create-content";

export default {
    name: "index",
    components: {RehydrationVehicleCreateContent, RehydrationVehicleDetailContent, RehydrationVehicleList},
    data() {
        return {
            showType: 'list',
            currDetail: {}
        }
    },
    methods: {
        handleAdd() {
            this.currDetail = null
            this.showType = 'add'
        },
        handleEdit(_detail) {
            this.currDetail = _detail
            this.showType = 'add'
        },
        handleBack(flag) {
            this.showType = 'list'
            if (flag) this.$refs.rehydrationVehicleListRef.query()
        },
        handleDetail(_detail) {
            this.currDetail = _detail
            this.showType = 'detail'
        }
    }
}
</script>

<style lang="scss" scoped>

</style>
